package com.officegame.restclient;

import java.util.Arrays;
import java.util.List;

import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import com.officegame.entities.GameTable;

public class GameTableRestHelper extends RestHelper {

	private final String tablesPath = "/tables";
	
	public List<GameTable> getGameTables() {
		String url = baseUrl + tablesPath;

		// Create a new RestTemplate instance
		RestTemplate restTemplate = new RestTemplate();

		// Add the String message converter
		restTemplate.getMessageConverters().add(
				new StringHttpMessageConverter());

		restTemplate.getMessageConverters().add(
				new MappingJacksonHttpMessageConverter());
		
		GameTable[] tables = restTemplate.getForObject(url, GameTable[].class);
		
		List<GameTable> list = Arrays.asList(tables); 
		
		return list;
	}
	
}
